<?php 
	header("Content-type:text/html;charset=utf-8");
	
    $client_name = $_GET["client_name"];
    $goods_id = $_GET["goods_id"];
    $goods_color = $_GET["goods_color"];
    $goods_sum = $_GET["goods_sum"];
    $goods_size = $_GET["goods_size"];
    $goods_text = $_GET["goods_text"];
	// 连接数据库
	$conn = mysql_connect("localhost","root","root");
	mysql_select_db("test");
	
	$result = mysql_query("select * from client_goods where client_name = $client_name and goods_id = $goods_id ",$conn);
	if(mysql_num_rows($result) > 0){
        while($obj = mysql_fetch_assoc($result)){
            $str =$obj["goods_sum"];
        }
        $str = $str + $goods_sum;
        mysql_query("update client_goods set goods_sum = $str where client_name = $client_name and goods_id = $goods_id",$conn);
	}else{
        mysql_query("insert into client_goods(client_name,goods_id,goods_color,goods_size,goods_text,goods_sum) values($client_name,$goods_id,'$goods_color',$goods_size,'$goods_text',$goods_sum)",$conn);
	}
	mysql_close($conn);
?>